package com.city.service.city.impl;

import com.city.domain.city.CityHouseinfo;
import com.city.repository.city.CityHouseinfoRepository;
import com.city.service.city.CityHouseinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @deprecation: 居民房屋信息表
 * @dmail: 398521613@qq.com
 * @author: L-H
 * @date: 2018-07-18 13:14
 */
@Service
public class CityHouseinfoServiceImpl implements CityHouseinfoService {

    @Autowired
    private CityHouseinfoRepository houseinfoRepository;

    @Override
    public List<CityHouseinfo> getHouseinfoLimit(Integer limitPage, Integer limitNum) {
        return houseinfoRepository.getHouseinfoLimit((limitPage - 1) * limitNum, limitNum);
    }

    @Override
    public CityHouseinfo getHouseinfo(Integer id) {
        return houseinfoRepository.getHouseinfo(id);
    }


    @Override
    public List<CityHouseinfo> getHouseinfo(CityHouseinfo cityHouseinfo) {
        //创建匹配器，即如何使用查询条件
        ExampleMatcher matcher = ExampleMatcher.matching(); //构建对象

        //创建实例
        Example<CityHouseinfo> ex = Example.of(cityHouseinfo, matcher);

        //查询
        return houseinfoRepository.findAll(ex);
    }

    @Override
    public long count(){return houseinfoRepository.count();}
}
